﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GPS.COMMON;
using WordDocumentGenerator.Library;
using System.IO;

namespace GPS.ENTITYS
{
   public  class GPS_EXPORT_OPENDOOR
    {
       public string MA { get; set; }
       public string TEN { get; set; }
       public string NGAY { get; set; }

       public List<GPS_EXPORT_OPENDOOR> LIST_1 { get; set; }
    }

   public class EXPORTWORD_OPENDOOR
   {
       public static byte[] EXPORT_OPENDOOR(string templateFileName, object objSource, string docType)
       {
           DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);

           COMMON.ExportCore<GPS_EXPORT_OPENDOOR> docGenerator = new COMMON.ExportCore<GPS_EXPORT_OPENDOOR>(generationInfo);

           return docGenerator.GenerateDocument();
       }
       /// <summary>
       /// Gets the document generation info.
       /// </summary>
       /// <param name="docType">Type of the doc.</param>
       /// <param name="docVersion">The doc version.</param>
       /// <param name="dataContext">The data context.</param>
       /// <param name="fileName">Name of the file.</param>
       /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
       /// <returns></returns>
       private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
       {
           DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
           generationInfo.Metadata = new DocumentMetadata
           {
               DocumentType = docType,
               DocumentVersion = docVersion
           };
           generationInfo.DataContext = dataContext;
           generationInfo.TemplateData = File.ReadAllBytes(fileName);
           generationInfo.IsDataBoundControls = useDataBoundControls;

           return generationInfo;
       }

   }
}
